local _, GrifonOvaleScripts = ...

GrifonOvaleScripts.script.SHAMAN.Attilio = {
	desc = "[5.4] Attilio: Enhancement, Elemental",
	code = [[
Define(ancestral_guidance 108281)
	SpellInfo(ancestral_guidance cd=120 duration=10)
	SpellAddBuff(ancestral_guidance ancestral_guidance=1)
Define(ancestral_guidance_talent 14)
Define(ancestral_swiftness 16188)
	SpellInfo(ancestral_swiftness cd=90)
	SpellAddBuff(ancestral_swiftness ancestral_swiftness=1)
Define(ancestral_swiftness_talent 11)
Define(ascendance 114049)
	SpellInfo(ascendance cd=180)
Define(ascendance_air 114051)
	SpellInfo(ascendance_air cd=180 duration=15)
Define(ascendance_fire 114050)
	SpellInfo(ascendance_fire cd=180 duration=15)
Define(ascendance_water 114052)
	SpellInfo(ascendance_water cd=180 duration=15)
Define(astral_shift 108271)
	SpellInfo(astral_shift cd=120 duration=6)
	SpellAddBuff(astral_shift astral_shift=1)
Define(astral_shift_talent 3)
Define(bloodlust 2825)
	SpellInfo(bloodlust cd=300 duration=40)
	SpellAddBuff(bloodlust bloodlust=1)
Define(call_of_the_elements 108285)
	SpellInfo(call_of_the_elements cd=180)
Define(call_of_the_elements_talent 7)
Define(capacitor_totem 108269)
	SpellInfo(capacitor_totem cd=45 duration=5)
	SpellInfo(capacitor_totem addduration=-2 glyph=glyph_of_capacitor_totem)
Define(chain_heal 1064)
	SpellInfo(chain_heal cd=4 glyph=glyph_of_chaining)
	SpellAddBuff(chain_heal ancestral_swiftness=0)
Define(chain_lightning 421)
	SpellInfo(chain_lightning cd=3)
	SpellAddBuff(chain_lightning ancestral_swiftness=0)
Define(cleanse_spirit 51886)
	SpellInfo(cleanse_spirit cd=8)
Define(clearcasting 16246)
	SpellInfo(clearcasting duration=15)
Define(conductivity_talent 15)
Define(earth_elemental_totem 2062)
	SpellInfo(earth_elemental_totem cd=300 duration=60)
Define(earth_shield 974)
	SpellInfo(earth_shield duration=600)
Define(earth_shock 8042)
	SpellInfo(earth_shock cd=6 sharedcd=shock)
	SpellInfo(earth_shock addcd=-1 specialization=1)
	SpellAddTargetDebuff(earth_shock weakened_blows=1)
Define(earthbind_totem 2484)
	SpellInfo(earthbind_totem cd=30 duration=20)
Define(earthgrab_totem 51485)
	SpellInfo(earthgrab_totem cd=30 duration=20)
Define(earthgrab_totem_talent 5)
Define(earthliving 51945)
	SpellInfo(earthliving duration=12 haste=spell tick=3)
Define(earthliving_weapon 51730)
Define(earthquake 61882)
	SpellInfo(earthquake cd=10 duration=10)
Define(earthquake_debuff 77478)
Define(echo_of_the_elements_talent 12)
Define(elemental_blast 117014)
	SpellInfo(elemental_blast cd=12)
	SpellAddBuff(elemental_blast elemental_blast_buff=1)
Define(elemental_blast_buff 118522)
	SpellInfo(elemental_blast_buff duration=8)
Define(elemental_blast_talent 18)
Define(elemental_mastery 16166)
	SpellInfo(elemental_mastery cd=90 duration=20)
	SpellAddBuff(elemental_mastery elemental_specialization=1)
Define(elemental_mastery_talent 10)
Define(far_sight 6196)
	SpellInfo(far_sight duration=60)
	SpellAddBuff(far_sight ancestral_swiftness=0 far_sight=1)
Define(feral_spirit 51533)
	SpellInfo(feral_spirit cd=120 duration=30)
Define(fire_elemental_totem 2894)
	SpellInfo(fire_elemental_totem cd=300 duration=60)
	SpellInfo(fire_elemental_totem cd=180 duration=36 glyph=glyph_of_fire_elemental_totem)
Define(fire_nova 1535)
	SpellInfo(fire_nova cd=4)
Define(flame_shock 8050)
	SpellInfo(flame_shock cd=6 duration=30 haste=spell sharedcd=shock tick=3)
	SpellInfo(flame_shock addcd=-1 specialization=1)
	SpellAddBuff(flame_shock unleash_flame=0)
	SpellAddTargetDebuff(flame_shock flame_shock=1)
Define(flametongue_weapon 8024)
Define(flurry 16278)
	SpellInfo(flurry duration=15)
Define(frost_shock 8050)
	SpellInfo(frost_shock cd=6 duration=8 sharedcd=shock)
	SpellInfo(frost_shock addduration=2 glyph=glyph_of_frost_shock)
	SpellAddTargetDebuff(frost_shock frost_shock=1)
Define(frostbrand_weapon 8033)
Define(ghost_wolf 2645)
Define(glyph_of_capacitor_totem 55442)
Define(glyph_of_chaining 55452)
Define(glyph_of_fire_elemental_totem 55455)
Define(glyph_of_frost_shock 55443)
Define(glyph_of_grounding_totem 55441)
Define(glyph_of_hex 63291)
Define(glyph_of_purge 55439)
Define(glyph_of_riptide 63273)
Define(glyph_of_spirit_walk 55454)
Define(glyph_of_spiritwalkers_grace 55446)
Define(glyph_of_totemic_recall 55438)
Define(glyph_of_the_lakestrider 55448)
Define(glyph_of_thunder 63270)
Define(glyph_of_wind_shear 55451)
Define(greater_healing_wave 77472)
	SpellAddBuff(greater_healing_wave ancestral_swiftness=0 tidal_waves=-1 unleash_life=0)
Define(grounding_totem 8177)
	SpellInfo(grounding_totem cd=25 duration=15)
	SpellInfo(grounding_totem addcd=35 glyph=glyph_of_grounding_totem)
Define(healing_rain 73920)
	SpellInfo(healing_rain cd=10 duration=10 haste=spell tick=2)
	SpellAddBuff(healing_rain ancestral_swiftness=0 unleash_life=0)
Define(healing_stream_totem 5394)
	SpellInfo(healing_stream_totem cd=30 duration=15)
Define(healing_surge 8004)
	SpellAddBuff(healing_surge ancestral_swiftness=0 tidal_waves=-1 unleash_life=0)
Define(healing_tide_totem 108280)
	SpellInfo(healing_tide_totem cd=180 duration=11)
Define(healing_tide_totem_talent 13)
Define(healing_wave 331)
	SpellAddBuff(healing_wave ancestral_swiftness=0 tidal_waves=-1 unleash_life=0)
Define(heroism 32182)
	SpellInfo(heroism duration=40 cd=300)
	SpellAddBuff(heroism heroism=1)
Define(hex 51514)
	SpellInfo(hex cd=45 duration=60)
	SpellInfo(hex addcd=-10 glyph=glyph_of_hex)
	SpellAddBuff(hex ancestral_swiftness=0)
	SpellAddTargetDebuff(hex hex=1)
Define(lava_beam 114074)
Define(lava_burst 51505)
	SpellInfo(lava_burst buffnocd=ascendance_fire cd=8)
	SpellAddBuff(lava_burst clearcasting=-1 lava_surge=0)
Define(lava_lash 60103)
	SpellInfo(lava_lash cd=10)
	SpellAddBuff(lava_lash searing_flames=0)
Define(lava_surge 77762)
	SpellInfo(lava_surge duration=6)
Define(lightning_bolt 403)
	SpellAddBuff(lightning_bolt ancestral_swiftness=0)
Define(lightning_shield 324)
	SpellInfo(lightning_shield duration=3600)	# maximum of 7 charges
	SpellAddBuff(lightning_shield lightning_shield=1 water_shield=0)
Define(maelstrom_weapon 53817)
	SpellInfo(maelstrom_weapon duration=30)		# stacks 5 times
	SpellAddBuff(maelstrom_weapon maelstrom_weapon=1)
Define(magma_totem 8187)
	SpellInfo(magma_totem duration=60 tick=2)
Define(mana_tide_totem 16190)
	SpellInfo(mana_tide_totem cd=180 duration=16)
Define(primal_elementalist_talent 17)
Define(primal_strike 73899)
Define(purge 370)
	SpellInfo(purge cd=6 glyph=glyph_of_purge)
Define(purify_spirit 77130)
Define(riptide 61295)
	SpellInfo(riptide cd=6 duration=18 haste=spell tick=3)
	SpellInfo(riptide cd=0 glyph=glyph_of_riptide)
Define(rockbiter_weapon 8017)
Define(searing_flames 77661)
	SpellInfo(searing_flames duration=15)	# stacks 5 times
Define(searing_totem 3599)
	SpellInfo(searing_totem duration=60)
Define(shamanistic_rage 30823)
	SpellInfo(shamanistic_rage cd=60 duration=15)
Define(spirit_link_totem 98008)
	SpellInfo(spirit_link_totem cd=180 duration=6)
Define(spirit_walk 58875)
	SpellInfo(spirit_walk cd=60 duration=15)
	SpellInfo(spirit_walk addcd=-15 glyph=glyph_of_spirit_walk)
Define(spiritwalkers_grace 79206)
	SpellInfo(spiritwalkers_grace cd=120 duration=15)
	SpellInfo(spiritwalkers_grace addduration=5 glyph=glyph_of_spiritwalkers_grace)
	SpellAddBuff(spiritwalkers_grace spiritwalkers_grace=1)
Define(stone_bulwark_totem 108270)
	SpellInfo(stone_bulwark_totem cd=10 duration=30)
Define(stone_bulwark_totem_talent 2)
Define(stormblast 115356)
  SpellInfo(stormblast duration=15 sharedcd=strike cd=8 )
  SpellAddBuff(stormblast stormblast=1)
Define(stormlash 120687)
Define(stormlash_totem 120668)
	SpellInfo(stormlash_totem cd=300 duration=10)
	SpellAddBuff(stormlash_totem stormlash_totem_buff=1)
Define(stormlash_totem_buff 120676)
Define(stormstrike 17364)
	SpellInfo(stormstrike cd=8 duration=15 sharedcd=strike)
	SpellAddTargetDebuff(stormstrike stormstrike=1)
Define(thunderstorm 51490)
	SpellInfo(thunderstorm cd=45 duration=5)
	SpellInfo(thunderstorm addcd=-10 glyph=glyph_of_thunder)
	SpellAddBuff(thunderstorm thunderstorm=1)
Define(tidal_waves 53390)
	SpellInfo(tidal_waves duration=15)
Define(totemic_projection 108287)
	SpellInfo(totemic_projection cd=10)
Define(totemic_projection_talent 9)
Define(totemic_recall 36936)
Define(totemic_restoration_talent 8)
Define(tremor_totem 8143)
	SpellInfo(tremor_totem cd=60 duration=6)
Define(unleash_elements 73680)
	SpellInfo(unleash_elements cd=15)
Define(unleash_flame 73683)
	SpellInfo(unleash_flame cd=15 duration=8)
	SpellAddBuff(unleash_flame unleash_flame=1)
Define(unleash_life 73685)
	SpellInfo(unleash_life cd=15 duration=10)
	SpellAddBuff(unleash_life unleash_life=1)
Define(unleashed_fury_talent 16)
Define(water_shield 52127)
	SpellInfo(water_shield duration=3600)
	SpellAddBuff(water_shield lightning_shield=0 water_shield=1)
Define(water_walking 546)
	SpellInfo(water_walking duration=600)
Define(weakened_blows 115798)
	SpellInfo(weakened_blows duration=30)
Define(wind_shear 57994)
	SpellInfo(wind_shear cd=12 duration=3)
	SpellInfo(wind_shear addcd=3 addduration=1 glyph=glyph_of_wind_shear)
	SpellAddTargetDebuff(wind_shear wind_shear=1)
Define(windwalk_totem 108273)
	SpellInfo(windwalk_totem cd=60 duration=6)
Define(windwalk_totem_talent 6)
Define(windfury_weapon 8232)

# Pet spells (Primal Elementalist Talent)
Define(pet_empower 118350)
	SpellInfo(pet_empower cd=10 duration=60)
	SpellAddBuff(pet_empower pet_empower=1)
Define(pet_reinforce 118347)
	SpellInfo(pet_reinforce cd=10 duration=60)
	SpellAddBuff(pet_reinforce pet_reinforce=1)

# Items
Define(jade_serpent_potion 76093)
Define(jade_serpent_potion_buff 105702)
	SpellInfo(jade_serpent_potion_buff duration=25)
Define(virmens_bite_potion 76089)
Define(virmens_bite_potion_buff 105697)
	SpellInfo(virmens_bite_potion_buff duration=25)

# Racials
Define(berserking 26297)
	SpellInfo(berserking cd=180 duration=10)
	SpellAddBuff(berserking berserking=1)
Define(blood_fury 20572)
	SpellInfo(blood_fury cd=120 duration=15)
	SpellAddBuff(blood_fury blood_fury=1)
Define(stoneform 20594)
	SpellInfo(stoneform cd=120 duration=8)
	SpellAddBuff(stoneform stoneform=1)
Define(glyph_of_chaininig 55452)

AddFunction UseRacialActions
{
	Spell(berserking)
	Spell(blood_fury)
}

AddFunction UseRacialSurvivalActions
{
	Spell(stoneform)
}

AddCheckBox(autointerrupt "autointerrupt" default)
AddCheckBox(forceChainingAOE "forceChainingAOE" default)

AddCheckBox(autoheal "autoheal" default)

AddCheckBox(autoAOE "autoAOE" default)
AddCheckBox(autoElemental "Elementals" default)
AddCheckBox(autoElementalTotemOnBoss "ElementalsOnlyOnBoss" default)
AddCheckBox(autoAscendance "Ascendance" default)
AddCheckBox(autoAscendanceOnlyBOSS "AscendanceOnlyOnBOSS" default)
AddCheckBox(autoUseCD "autoUseCD" default)


#chainingLight
AddListItem(ChainingLightining cl1 "ChainingLightining 1")
AddListItem(ChainingLightining cl2 "ChainingLightining 2" default)
AddListItem(ChainingLightining cl3 "ChainingLightining 3")
AddListItem(ChainingLightining cl4 "ChainingLightining 4")
AddListItem(ChainingLightining cl5 "ChainingLightining 5")

#healingSurge
AddListItem(HealingSurge hs0  "HealingSurge 0")
AddListItem(HealingSurge hs2 "HealingSurge 20" default)
AddListItem(HealingSurge hs4 "HealingSurge 40")
AddListItem(HealingSurge hs6 "HealingSurge 60")
AddListItem(HealingSurge hs8 "HealingSurge 80")
AddListItem(HealingSurge hs10 "HealingSurge 100")

#healingRain
AddListItem(HealingRain hr0  "HealingRain 0")
AddListItem(HealingRain hr2 "HealingRain 20")
AddListItem(HealingRain hr4 "HealingRain 40")
AddListItem(HealingRain hr6 "HealingRain 60")
AddListItem(HealingRain hr8 "HealingRain 80" default)
AddListItem(HealingRain hr9 "HealingRain 90")
AddListItem(HealingRain hr10 "HealingRain 100")

#chainHeal
AddListItem(ChainHeal ch0  "ChainHeal 0")
AddListItem(ChainHeal ch2  "ChainHeal 20")
AddListItem(ChainHeal ch4  "ChainHeal 40")
AddListItem(ChainHeal ch6  "ChainHeal 60")
AddListItem(ChainHeal ch8  "ChainHeal 80" default)
AddListItem(ChainHeal ch9  "ChainHeal 90")
AddListItem(ChainHeal ch10 "ChainHeal 100")

#healingStreamTotem
AddListItem(HealingStreamTotem hst0   "HealingStreamTotem 0")
AddListItem(HealingStreamTotem hst2  "HealingStreamTotem 20")
AddListItem(HealingStreamTotem hst4  "HealingStreamTotem 40")
AddListItem(HealingStreamTotem hst6  "HealingStreamTotem 60")
AddListItem(HealingStreamTotem hst8  "HealingStreamTotem 80"default)
AddListItem(HealingStreamTotem hst10 "HealingStreamTotem 100")

#CDPlayersNumber
AddListItem(CDPlayersNumber cdnum1  "CDPlayersNumber 1")
AddListItem(CDPlayersNumber cdnum2  "CDPlayersNumber 2")
AddListItem(CDPlayersNumber cdnum3  "CDPlayersNumber 3" default)
AddListItem(CDPlayersNumber cdnum4  "CDPlayersNumber 4")
AddListItem(CDPlayersNumber cdnum5  "CDPlayersNumber 5")
AddListItem(CDPlayersNumber cdnum8  "CDPlayersNumber 8")

#healingTideTotem
AddListItem(HealingTideTotem htt0   "HealingTideTotem 0" default)
AddListItem(HealingTideTotem htt2  "HealingTideTotem 20")
AddListItem(HealingTideTotem htt4  "HealingTideTotem 40")
AddListItem(HealingTideTotem htt6  "HealingTideTotem 60")
AddListItem(HealingTideTotem htt8  "HealingTideTotem 80")
AddListItem(HealingTideTotem htt10 "HealingTideTotem 100")

#AncestralGuidance
AddListItem(AncestralGuidance ag0   "AncestralGuidance 0")
AddListItem(AncestralGuidance ag2  "AncestralGuidance 20")
AddListItem(AncestralGuidance ag4  "AncestralGuidance 40" default)
AddListItem(AncestralGuidance ag6  "AncestralGuidance 60")
AddListItem(AncestralGuidance ag8  "AncestralGuidance 80")
AddListItem(AncestralGuidance ag10 "AncestralGuidance 100")

#AncestralGuidance
AddListItem(ShamanisticRage sr0   "ShamanisticRage 0")
AddListItem(ShamanisticRage sr2  "ShamanisticRage 20")
AddListItem(ShamanisticRage sr4  "ShamanisticRage 40" default)
AddListItem(ShamanisticRage sr6  "ShamanisticRage 60")
AddListItem(ShamanisticRage sr8  "ShamanisticRage 80")
AddListItem(ShamanisticRage sr10 "ShamanisticRage 100")


AddFunction ShamanisticRageValue asValue=1
{
	if List(ShamanisticRage sr0) 0
	if List(ShamanisticRage sr2) 20
	if List(ShamanisticRage sr4) 40
	if List(ShamanisticRage sr6) 60
	if List(ShamanisticRage sr8) 80
	if List(ShamanisticRage sr10) 101   
}

AddFunction ChainingLightiningValue asValue=1
{
	if List(ChainingLightining cl1) 1
	if List(ChainingLightining cl2) 2
	if List(ChainingLightining cl3) 3
	if List(ChainingLightining cl4) 4
	if List(ChainingLightining cl5) 5    
}

AddFunction HealingSurgeValue asValue=1
{
	if List(HealingSurge hs0) 0
	if List(HealingSurge hs2) 20
	if List(HealingSurge hs4) 40
	if List(HealingSurge hs6) 60
	if List(HealingSurge hs8) 80
	if List(HealingSurge hs10) 101   
}

AddFunction HealingRainValue asValue=1
{
	if List(HealingRain hr0) 0
	if List(HealingRain hr2) 20
	if List(HealingRain hr4) 40
	if List(HealingRain hr6) 60
	if List(HealingRain hr8) 80
	if List(HealingRain hr9) 90
	if List(HealingRain hr10) 101   
}

AddFunction ChainHealValue asValue=1
{
	if List(ChainHeal ch0) 0
	if List(ChainHeal ch2) 20
	if List(ChainHeal ch4) 40
	if List(ChainHeal ch6) 60
	if List(ChainHeal ch8) 80
	if List(ChainHeal ch9) 90
	if List(ChainHeal ch10) 101   
}

AddFunction HealingStreamTotemValue asValue=1
{
	if List(HealingStreamTotem hst0) 0
	if List(HealingStreamTotem hst2) 20
	if List(HealingStreamTotem hst4) 40
	if List(HealingStreamTotem hst6) 60
	if List(HealingStreamTotem hst8) 80
	if List(HealingStreamTotem hst10) 101  
}

AddFunction CDPlayersNumberValue asValue=1
{
	if List(CDPlayersNumber cdnum1) 1
	if List(CDPlayersNumber cdnum2) 2
	if List(CDPlayersNumber cdnum3) 3
	if List(CDPlayersNumber cdnum4) 4
	if List(CDPlayersNumber cdnum5) 5
	if List(CDPlayersNumber cdnum8) 8   
}

AddFunction HealingTideTotemValue asValue=1
{
	if List(HealingTideTotem htt0) 0
	if List(HealingTideTotem htt2) 20
	if List(HealingTideTotem htt4) 40
	if List(HealingTideTotem htt6) 60
	if List(HealingTideTotem htt8) 80
	if List(HealingTideTotem htt10) 101   
}

AddFunction AncestralGuidanceValue asValue=1
{
	if List(AncestralGuidance ag0) 0
	if List(AncestralGuidance ag2) 20
	if List(AncestralGuidance ag4) 40
	if List(AncestralGuidance ag6) 60
	if List(AncestralGuidance ag8) 80
	if List(AncestralGuidance ag10) 101   
}

AddFunction UseItemActions
{
	Item(HandsSlot usable=1)
}

###
### Shaman (all specializations)
###

AddFunction Interrupt
{
	if CheckBoxOn(autointerrupt) and {target.IsFriend(no) or {target.IsFriend() and target.IsCharmed()} } and target.IsInterruptible() and target.InRange(wind_shear) Spell(wind_shear)
}



###
### Restoration
###





AddFunction AncestralGuidance
{
	if TalentPoints(ancestral_guidance_talent) 
	{
		if AncestralGuidanceValue() == 20  and {GetMembersNumBelow(20) >= CDPlayersNumberValue()} Spell(ancestral_guidance)
		if AncestralGuidanceValue() == 40  and {GetMembersNumBelow(40) >= CDPlayersNumberValue()} Spell(ancestral_guidance)
		if AncestralGuidanceValue() == 60  and {GetMembersNumBelow(60) >= CDPlayersNumberValue()} Spell(ancestral_guidance)
		if AncestralGuidanceValue() == 80  and {GetMembersNumBelow(80) >= CDPlayersNumberValue()} Spell(ancestral_guidance)
		if AncestralGuidanceValue() == 101 and {GetMembersNumBelow(101) >= CDPlayersNumberValue()} Spell(ancestral_guidance)
	}       

}

AddFunction HealingTideTotem
{
	if not TotemPresent(water) 
	{
		if HealingTideTotemValue() == 20  and {GetMembersNumBelow(20) >= CDPlayersNumberValue()} Spell(healing_tide_totem)
		if HealingTideTotemValue() == 40  and {GetMembersNumBelow(40) >= CDPlayersNumberValue()} Spell(healing_tide_totem)
		if HealingTideTotemValue() == 60  and {GetMembersNumBelow(60) >= CDPlayersNumberValue()} Spell(healing_tide_totem)
		if HealingTideTotemValue() == 80  and {GetMembersNumBelow(80) >= CDPlayersNumberValue()} Spell(healing_tide_totem)
		if HealingTideTotemValue() == 101 and {GetMembersNumBelow(101) >= CDPlayersNumberValue()} Spell(healing_tide_totem)
	}       

}

AddFunction HealingStreamTotem
{
	if not TotemPresent(water) 
	{
		if HealingStreamTotemValue() == 20  and {GetMembersNumBelow(20) >= CDPlayersNumberValue()} Spell(healing_stream_totem)
		if HealingStreamTotemValue() == 40  and {GetMembersNumBelow(40) >= CDPlayersNumberValue()} Spell(healing_stream_totem)
		if HealingStreamTotemValue() == 60  and {GetMembersNumBelow(60) >= CDPlayersNumberValue()} Spell(healing_stream_totem)
		if HealingStreamTotemValue() == 80  and {GetMembersNumBelow(80) >= CDPlayersNumberValue()} Spell(healing_stream_totem)
		if HealingStreamTotemValue() == 101 and {GetMembersNumBelow(101) >= CDPlayersNumberValue()} Spell(healing_stream_totem)
	}       

}

AddFunction HealingRainEnhancement
{
	if {Speed() == 0 or BuffPresent(spiritwalkers_grace)} and BuffStacks(maelstrom_weapon) == 5 
	{
		if HealingRainValue() == 20  and {GetMemberNumBelowHpInRangePlayer(20 15) >= CDPlayersNumberValue()} Spell(healing_rain)
		if HealingRainValue() == 40  and {GetMemberNumBelowHpInRangePlayer(40 15) >= CDPlayersNumberValue()} Spell(healing_rain)
		if HealingRainValue() == 60  and {GetMemberNumBelowHpInRangePlayer(60 15) >= CDPlayersNumberValue()} Spell(healing_rain)
		if HealingRainValue() == 80  and {GetMemberNumBelowHpInRangePlayer(80 15) >= CDPlayersNumberValue()} Spell(healing_rain)
		if HealingRainValue() == 90  and {GetMemberNumBelowHpInRangePlayer(90 15) >= CDPlayersNumberValue()} Spell(healing_rain)
		if HealingRainValue() == 101 and {GetMemberNumBelowHpInRangePlayer(101 15) >= CDPlayersNumberValue()} Spell(healing_rain)
	}       

}

AddFunction ChainHealEnhancement
{
	if BuffStacks(maelstrom_weapon) == 5 
	{
		if not Glyph(glyph_of_chaininig)
		{
			if ChainHealValue() == 20  and {GetMemberNumBelowHpInRangePlayer(20 13) >= CDPlayersNumberValue()} Spell(chain_heal)
			if ChainHealValue() == 40  and {GetMemberNumBelowHpInRangePlayer(40 13) >= CDPlayersNumberValue()} Spell(chain_heal)
			if ChainHealValue() == 60  and {GetMemberNumBelowHpInRangePlayer(60 13) >= CDPlayersNumberValue()} Spell(chain_heal)
			if ChainHealValue() == 80  and {GetMemberNumBelowHpInRangePlayer(80 13) >= CDPlayersNumberValue()} Spell(chain_heal)
			if ChainHealValue() == 90  and {GetMemberNumBelowHpInRangePlayer(90 13) >= CDPlayersNumberValue()} Spell(chain_heal)
			if ChainHealValue() == 101 and {GetMemberNumBelowHpInRangePlayer(101 13) >= CDPlayersNumberValue()} Spell(chain_heal)
		}
		if Glyph(glyph_of_chaininig)
		{
			if ChainHealValue() == 20  and {GetMemberNumBelowHpInRangePlayer(20 26) >= CDPlayersNumberValue()} Spell(chain_heal)
			if ChainHealValue() == 40  and {GetMemberNumBelowHpInRangePlayer(40 26) >= CDPlayersNumberValue()} Spell(chain_heal)
			if ChainHealValue() == 60  and {GetMemberNumBelowHpInRangePlayer(60 26) >= CDPlayersNumberValue()} Spell(chain_heal)
			if ChainHealValue() == 80  and {GetMemberNumBelowHpInRangePlayer(80 26) >= CDPlayersNumberValue()} Spell(chain_heal)
			if ChainHealValue() == 90  and {GetMemberNumBelowHpInRangePlayer(90 26) >= CDPlayersNumberValue()} Spell(chain_heal)
			if ChainHealValue() == 101 and {GetMemberNumBelowHpInRangePlayer(101 26) >= CDPlayersNumberValue()} Spell(chain_heal)
		}

	}       

}

AddFunction HealingRainElemental
{
	if {Speed() == 0 or BuffPresent(spiritwalkers_grace)} and not BuffPresent(healing_rain)
	{
		if HealingRainValue() == 20  and {GetMemberNumBelowHpInRangePlayer(20 15) >= CDPlayersNumberValue()} Spell(healing_rain)
		if HealingRainValue() == 40  and {GetMemberNumBelowHpInRangePlayer(40 15) >= CDPlayersNumberValue()} Spell(healing_rain)
		if HealingRainValue() == 60  and {GetMemberNumBelowHpInRangePlayer(60 15) >= CDPlayersNumberValue()} Spell(healing_rain)
		if HealingRainValue() == 80  and {GetMemberNumBelowHpInRangePlayer(80 15) >= CDPlayersNumberValue()} Spell(healing_rain)
		if HealingRainValue() == 90  and {GetMemberNumBelowHpInRangePlayer(90 15) >= CDPlayersNumberValue()} Spell(healing_rain)
		if HealingRainValue() == 101 and {GetMemberNumBelowHpInRangePlayer(101 15) >= CDPlayersNumberValue()} Spell(healing_rain)
	}       

}






###
### Enhancement
###

AddFunction Heal
{
	if player.HealthPercent() <= ShamanisticRageValue() Spell(shamanistic_rage)
	AncestralGuidance()
	HealingTideTotem()
	HealingStreamTotem()
	ChainHealEnhancement()
	HealingRainEnhancement()
	if {Speed() == 0 or BuffPresent(spiritwalkers_grace)} and BuffStacks(maelstrom_weapon) ==5 and player.HealthPercent() <= HealingSurgeValue() Spell(healing_surge)
}

AddFunction FullRotation
{
	if WeaponEnchantExpires(mainhand) Spell(windfury_weapon)
	if WeaponEnchantExpires(offhand) Spell(flametongue_weapon)
	if not BuffPresent(lightning_shield) Spell(lightning_shield)
        
	if CheckBoxOn(autoheal) Heal()
        Interrupt()
	#UseItemActions()

        if not TotemPresent(fire)
	{
		if Enemies() <= 5 Spell(searing_totem)
        	if Enemies() > 5 and target.InRange(lava_lash) Spell(magma_totem)
	}
	if CheckBoxOn(autoElemental)
	{
		if {CheckBoxOn(autoElementalTotemOnBoss) and target.Classification(worldboss)} or not CheckBoxOn(autoElementalTotemOnBoss)
		{
			Spell(fire_elemental_totem)
			if SpellCooldown(fire_elemental_totem) >=60 Spell(earth_elemental_totem)	
		}
	
        }
	if CheckBoxOn(autoUseCD)
	{
		if TalentPoints(ancestral_swiftness_talent) Spell(ancestral_swiftness)	
		if BuffExpires(stormlash_totem_buff any=1) Spell(stormlash_totem)
		if TalentPoints(elemental_mastery_talent) and BuffPresent(ascendance_fire) Spell(elemental_mastery)
	}
	if Enemies() >=3 and target.DebuffPresent(flame_shock) Spell(fire_nova)
	if TalentPoints(unleashed_fury_talent) and target.InRange(unleash_elements) Spell(unleash_elements)
	if BuffStacks(maelstrom_weapon) ==5 
	{
                if TalentPoints(elemental_blast_talent) and target.InRange(unleash_elements) Spell(elemental_blast)
		if {CheckBoxOn(forceChainingAOE) or {CheckBoxOn(autoAOE) and Enemies() >= ChainingLightiningValue() }} and target.InRange(lightning_bolt) Spell(chain_lightning) 
                if target.InRange(lightning_bolt) Spell(lightning_bolt)
        }
        if CheckBoxOn(autoAscendance) and not BuffPresent(ascendance_air)
	{	
		if CheckBoxOn(autoAscendanceOnlyBOSS) and target.Classification(worldboss) Spell(ascendance)
		if not CheckBoxOn(autoAscendanceOnlyBOSS) Spell(ascendance)	
	}
	if BuffPresent(ascendance_air) and target.InRange(lightning_bolt) Spell(stormstrike)
	if target.InRange(lava_lash) Spell(stormstrike)
        Spell(feral_spirit)
	if target.InRange(flame_shock) and BuffPresent(unleash_flame) and not target.DebuffPresent(flame_shock) Spell(flame_shock)
	if target.InRange(lava_lash) Spell(lava_lash)
        if target.InRange(unleash_elements)  Spell(unleash_elements)
	if ArmorSetParts(T15 more 2) ==1 and BuffStacks(maelstrom_weapon) >=4 and target.InRange(lightning_bolt) Spell(lightning_bolt)
	if {BuffPresent(unleash_flame) or {not BuffPresent(unleash_flame) and not target.DebuffPresent(flame_shock) and SpellCooldown(unleash_elements) >5 }} and target.InRange(flame_shock) Spell(flame_shock)
	if not TalentPoints(unleashed_fury_talent) and target.InRange(unleash_elements)  Spell(unleash_elements)
	if target.DebuffRemains(flame_shock) > 6 and target.InRange(earth_shock) Spell(earth_shock)

}

AddIcon specialization=2 help=main
{
	FullRotation()
}



















###
### Elemental
###


AddFunction ElementalHeal
{
	if player.HealthPercent() <= ShamanisticRageValue() Spell(shamanistic_rage)
	AncestralGuidance()
	HealingTideTotem()
	HealingStreamTotem()
	HealingRainElemental()
	if {Speed() == 0 or BuffPresent(spiritwalkers_grace)} and player.HealthPercent() <= HealingSurgeValue() Spell(healing_surge)
}

AddFunction ElementalFullAOERotation
{
	if WeaponEnchantExpires(mainhand 2) Spell(flametongue_weapon)
	if not BuffPresent(lightning_shield) Spell(lightning_shield)	
	

	if CheckBoxOn(autoheal) ElementalHeal()
        Interrupt()
	#UseItemActions()
        if ManaPercent() <75 Spell(thunderstorm)

	if InCombat() and Speed() >0 and BuffPresent(ascendance_fire) Spell(spiritwalkers_grace)
	
	if CheckBoxOn(autoUseCD)
	{
		if TalentPoints(ancestral_swiftness_talent) Spell(ancestral_swiftness)	
		if BuffExpires(stormlash_totem_buff any=1) Spell(stormlash_totem)
		if TalentPoints(elemental_mastery_talent) and BuffPresent(ascendance_fire) Spell(elemental_mastery)
	}

        if CheckBoxOn(autoAscendance) and not BuffPresent(ascendance_fire)
	{	
		if CheckBoxOn(autoAscendanceOnlyBOSS) and target.Classification(worldboss) Spell(ascendance)
		if not CheckBoxOn(autoAscendanceOnlyBOSS) Spell(ascendance)	
	}

	if CheckBoxOn(autoElemental)
	{
		if {CheckBoxOn(autoElementalTotemOnBoss) and target.Classification(worldboss)} or not CheckBoxOn(autoElementalTotemOnBoss)
		{
			Spell(fire_elemental_totem)
			if SpellCooldown(fire_elemental_totem) >=60 Spell(earth_elemental_totem)	
		}
	
        }
	if TotemExpires(fire)
	{
		if Enemies() > 5 and target.InRange(lava_lash) Spell(magma_totem)
		Spell(searing_totem)        	
	}
	if InCombat() and Speed() >0
	{
		if {TalentPoints(elemental_blast_talent) and Spell(elemental_blast)} or {Spell(lava_burst) and BuffExpires(lava_surge)} Spell(spiritwalkers_grace)
	}
	if BuffPresent(ascendance_fire)  Spell(lava_beam)
	Spell(chain_lightning)

}

AddFunction ElementalFullRotation
{
	if WeaponEnchantExpires(mainhand 2) Spell(flametongue_weapon)
	if not BuffPresent(lightning_shield) Spell(lightning_shield)	
	

	if CheckBoxOn(autoheal) ElementalHeal()
        Interrupt()
	#UseItemActions()
        if ManaPercent() <75 Spell(thunderstorm)

	if InCombat() and Speed() >0 and BuffPresent(ascendance_fire) Spell(spiritwalkers_grace)
	
	if CheckBoxOn(autoUseCD)
	{
		if TalentPoints(ancestral_swiftness_talent) Spell(ancestral_swiftness)	
		if BuffExpires(stormlash_totem_buff any=1) Spell(stormlash_totem)
		if TalentPoints(elemental_mastery_talent) and BuffPresent(ascendance_fire) Spell(elemental_mastery)
	}

	if TalentPoints(unleashed_fury_talent) and target.InRange(unleash_elements) Spell(unleash_elements)
        if CheckBoxOn(autoAscendance) and not BuffPresent(ascendance_fire)
	{	
		if CheckBoxOn(autoAscendanceOnlyBOSS) and target.Classification(worldboss) Spell(ascendance)
		if not CheckBoxOn(autoAscendanceOnlyBOSS) Spell(ascendance)	
	}

	if Enemies() <= 3 or not CheckBoxOn(autoAOE)
	{
		if {Speed() == 0 or BuffPresent(lava_surge) or BuffPresent(spiritwalkers_grace)} 
			and target.DebuffRemains(flame_shock) > CastTime(lava_burst) and {BuffPresent(ascendance_fire) or Spell(lava_burst)} 
			and target.InRange(lava_burst) Spell(lava_burst)
		if {not target.DebuffPresent(flame_shock) or target.TicksRemain(flame_shock) < 2} and target.InRange(flame_shock) Spell(flame_shock)
		if TalentPoints(elemental_blast_talent) and {Speed() == 0 or BuffPresent(spiritwalkers_grace)} and target.InRange(elemental_blast) Spell(elemental_blast)
		if BuffStacks(lightning_shield) >6 and target.InRange(earth_shock) Spell(earth_shock)
		if BuffStacks(lightning_shield) >3
			and target.DebuffRemains(flame_shock) > SpellCooldown(earth_shock)
			and target.DebuffRemains(flame_shock) < SpellCooldown(earth_shock) + target.NextTick(flame_shock)
			and target.InRange(earth_shock)
		{
			Spell(earth_shock)
		}
		if TimeInCombat() >60
			and target.DebuffRemains(flame_shock) <= SpellData(ascendance_fire duration)
			and SpellCooldown(ascendance_fire) + SpellData(ascendance_fire duration) < SpellData(flame_shock duration)
		{
			Spell(flame_shock)
		}
	}	

	if CheckBoxOn(autoElemental)
	{
		if {CheckBoxOn(autoElementalTotemOnBoss) and target.Classification(worldboss)} or not CheckBoxOn(autoElementalTotemOnBoss)
		{
			Spell(fire_elemental_totem)
			if SpellCooldown(fire_elemental_totem) >=60 Spell(earth_elemental_totem)	
		}
	
        }
	if TotemExpires(fire)
	{
		if Enemies() > 5 and target.InRange(lava_lash) Spell(magma_totem)
		Spell(searing_totem)        	
	}
	if InCombat() and Speed() >0
	{
		if {TalentPoints(elemental_blast_talent) and Spell(elemental_blast)} or {Spell(lava_burst) and BuffExpires(lava_surge)} Spell(spiritwalkers_grace)
	}
	if {CheckBoxOn(forceChainingAOE) or {CheckBoxOn(autoAOE) and Enemies() >= ChainingLightiningValue() }} and {Speed() == 0 or BuffPresent(spiritwalkers_grace)} and target.InRange(lightning_bolt)
	{
		if BuffPresent(ascendance_fire)  Spell(lava_beam)
		Spell(chain_lightning)

	}
	if {not CheckBoxOn(autoAOE) or Enemies() < ChainingLightiningValue()} and target.InRange(lightning_bolt) and not CheckBoxOn(forceChainingAOE) Spell(lightning_bolt)
}



AddIcon specialization=1 help=main
{
	ElementalFullRotation()
}

AddIcon specialization=1 help=aoe
{
	ElementalFullAOERotation()
}





]],
}
